package io.lckgroup.modules.lck.controller;

import java.util.Arrays;
import java.util.Map;

import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import io.lckgroup.modules.lck.entity.ShopFoodSpecEntity;
import io.lckgroup.modules.lck.service.ShopFoodSpecService;
import io.lckgroup.common.utils.PageUtils;
import io.lckgroup.common.utils.R;


/**
 * 菜品规格表
 *
 * @author srq
 * @email siruiqi@siruiqi.com
 * @date 2020-01-19 19:14:39
 */
@RestController
@RequestMapping("diancan/shopfoodspec")
public class ShopFoodSpecController {
    @Autowired
    private ShopFoodSpecService shopFoodSpecService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    @RequiresPermissions("diancan:shopfoodspec:list")
    public R list(@RequestParam Map<String, Object> params) {
        PageUtils page = shopFoodSpecService.queryPage(params);
        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{id}")
    @RequiresPermissions("diancan:shopfoodspec:info")
    public R info(@PathVariable("id") Long id) {
        ShopFoodSpecEntity shopFoodSpec = shopFoodSpecService.getById(id);
        return R.ok().put("shopFoodSpec", shopFoodSpec);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    @RequiresPermissions("diancan:shopfoodspec:save")
    public R save(@RequestBody ShopFoodSpecEntity shopFoodSpec) {
        shopFoodSpecService.save(shopFoodSpec);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    @RequiresPermissions("diancan:shopfoodspec:update")
    public R update(@RequestBody ShopFoodSpecEntity shopFoodSpec) {
        shopFoodSpecService.updateById(shopFoodSpec);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    @RequiresPermissions("diancan:shopfoodspec:delete")
    public R delete(@RequestBody Long[] ids) {
        shopFoodSpecService.removeByIds(Arrays.asList(ids));
        return R.ok();
    }

}
